Lalr - A Generator for Efficient Parsers
نویسنده
چکیده
1 SUMMARY Lalr is a parser generator that generates very fast and powerful parsers. The design goals have been to generate portable, table-drivenparsers that areasefficient as possible and which include all the features needed for practical applications. Like Yacc it accepts LALR(1) grammars, resolves ambiguities with precedence and associativ-ity of operators, generates table-drivenp arsers, and has a mechanism for S-attribution. Unlike Yacc it allows grammars to be written in extended BNF,i ncludes automatic error reporting, recovery,a nd repair,a nd generates parsers in C or Modula-2. In case of LR-conflicts, a derivation tree is printed instead of the involved states and items in order to aid the location of the problem. The parsers aretwo tothree times faster as those of Yacc. Using a MC 68020 processor,35,000 tokens per second or 580,000 lines per minute can be parsed. The sources of Lalr exist in C and in Modula-2. We describe in detail the development steps of the generated parsers. We show howsoftwareengineering methods likepseudo code and stepwise refinement can turnaparsing algorithm from a textbook into a complete and efficient implementation. Wepresent the details of the generated parsers and show howt he performance is achievedw ith a relatively simple and short program. Wed iscuss important features of the generator and finally present a comparison of some parser generators.
منابع مشابه
An LALR Parser Generator Supporting Conflict Resolution
Despite all the advance brought by LALR parsing method by DeRemer in the late 60’s, conflicts continue to be removed in a non-productive way, by means of analysis of a huge amount of textual and low level data dumped by the parser generator tool. For the purpose of changing this scenario, we present a parser generator capable of automatically removing some types of conflicts, along with a suppo...
متن کاملIncremental Generation of LR Parsers
Implementation of a new compiler usually requires making frequent adjustments to grammar de nitions. An incremental technique for updating the parser tables after a minor change to the grammar could potentially save much computational e ort. More importantly, debugging a grammar is made easier if the grammar is re-checked for correctness after each small change to the grammar. The basic design ...
متن کاملRecursive Ascent-Descent Parsing
Generalized left-corner parsing was originally presented as a technique for generating a parser for the SLR(1) class of grammars but with far fewer states than the SLR(1) parser. This paper modi es and extends the formulation of left-corner parsers so that it is possible to apply the technique to the LALR(1) and LR(1) classes of grammars. It is further shown that left-corner parsers can be conv...
متن کاملNoncanonical LALR(1) Parsing
A construction for noncanonical LALR(1) parsers is presented. The class of NLALR(1) grammars is a proper superclass of the NSLR(1) and LALR(1) grammar classes. The recognized languages include some non deterministic languages, but the generated machines parse their input deterministically in linear time using the input as a second stack. The construction is a natural extension to the canonical ...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- Softw., Pract. Exper.
دوره 20 شماره
صفحات -
تاریخ انتشار 1990